package com.xiaofu.quartz;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author luofuzhou
 * @date 2024/11/23
 * @dec 描述
 */
public class SimpleQuartz {
    public static void main(String[] args) throws SchedulerException {
        JobDetail jobDetail = JobBuilder.newJob(DemoJob.class).withIdentity("xiaofu", "test")
                .usingJobData("swer", "xiaofu")
                .usingJobData("saturday", "week")
                .build();

        SimpleTrigger trigger = TriggerBuilder.newTrigger().withIdentity("xiaofu", "test")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(2).repeatForever())
                .build();


        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.scheduleJob(jobDetail, trigger);
        scheduler.start();

    }
}

